<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.io.*,java.text.*" %>
<html>
<head>
    <title>Web文件操作</title>
</head>
<body>
<%
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String filePath = this.getServletContext().getRealPath("/uploads/");
    File file = new File(filePath);
    File result [] = file.listFiles(); // 获取文件列表
%>
<h2>当前访问路径：<%=filePath%></h2>
<table border="1">
    <thead>
    <tr>
        <td style="width: 200px;">文件名称</td>
        <td style="width: 200px;">文件大小</td>
        <td style="width: 200px;">最后一次修改日期</td>
    </tr>
    </thead>
    <tbody>
    <%
        for (int x = 0; x < result.length; x++) {
    %>
    <tr>
        <td><a href="test04_load.jsp?fname=<%=result[x].getName()%>"><%=result[x].getName()%></a></td>
        <td><%=result[x].length()%></td>
        <td><%=sdf.format(new java.util.Date(result[x].lastModified()))%></td>
    </tr>
    <%
        }
    %>
    </tbody>
</table>
</body>
</html>
